/*******************************************************************
 *
 * Copyright (C), 2021-2022, Letstrong, All rights reserved.
 *
 * Author      : 
 * Create Time : 2021-6-21
 * Version     : v0.1
 * Description : 
 *******************************************************************/
 
/*----------------------------Head file----------------------------*/
#include "wm.h"
#include "string.h"
#include "app_reset.h"
#include "app_skip_alg.h"
#include "app_global_data.h"
#include "app_store_set_info.h"
#include "user_config.h"

#if(DEV_MAC_BURN_ENABLE)

/*----------------------------macro file---------------------------*/

/*----------------------------type define--------------------------*/

/*----------------------------var define---------------------------*/

/*-------------------------func declaration------------------------*/
extern void skip_disp_1hz_update(void);

/*-----------------------------------------------------------------*/

static void wm_sn_disp_short_press_cb(void)
{
    ui_revert_last_skip_mode_disp(false);
}

void wm_sn_disp(void)
{
	wm_t wm;
	
	memset((uint8_t*)&wm, 0, sizeof(wm));
	wm.cur_win = SN_WIN;
    wm.revert_win = wm_get_revert_win();
	wm.disp_off_cnt = DISP_NEVER_OFF_CNT;
    wm.auto_update_1hz_cb = skip_disp_1hz_update;
	wm.short_press_cb = wm_sn_disp_short_press_cb;

	wm_info_set(&wm);
	
	//app_skip_mode_set(SKIP_MODE_NULL);
	
	uint8_t mac[DEV_MAC_LEN];
	uint8_t sn[DEV_SN_NUM];
	memset(sn, 0, sizeof(sn));
	
	//for test
	//uint8_t mac1[DEV_MAC_LEN] = {0x78, 0x56, 0x34, 0x12, 0xA0, 0xFC};
	//app_set_info_burn_mac_save(mac1, sizeof(mac1));
	//#include "hal_flash.h"
	//hal_nvr_erase_sector(BURN_INFO_START_ADDR);

	if(DEV_MAC_LEN == app_set_info_burn_mac_get(mac))
	{
		for(uint8_t i=0;i<(DEV_SN_NUM/2);i++) {
			sn[i*2] = mac[(DEV_SN_NUM/2-1)-i]/0x10;
			sn[i*2+1] = mac[(DEV_SN_NUM/2-1)-i]%0x10;
		}
	}
	
	app_disp_clear();
	app_disp_sn(sn, sizeof(sn));
	app_disp_update();
	
	wm_set_backlight_off_cnt(DISP_NEVER_OFF_CNT);
	app_disp_backlight_set(true);
}


#endif
